using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Rensoft.CRM.Client.AccountsAPI;
using Rensoft.CRM.Client.Editors;
using Rensoft.CRM.Client.Properties;

namespace Rensoft.CRM.Client.ItemViews
{
    public partial class InvoiceSalesView : Rensoft.CRM.Client.ItemViews.InvoiceView
    {
        public override Image NewButtonImage
        {
            get
            {
                return Resources.SalesInvoices;
            }
        }

        public InvoiceSalesView(Program program) : base(program)
        {
            InitializeComponent();
        }

        protected override void PerformLoad()
        {
            base.PerformLoad();

            AccountsService accountsService = new AccountsService();
            accountsService.UseDefaultCredentials = true;
            InvoiceArray = accountsService.InvoiceFetch(InvoiceType.Client);
        }

        internal override BaseEditor GetEditor()
        {
            return new InvoiceSalesEditor(Program);
        }

        protected override void PerformEditorOpen(object tag)
        {
            Invoice invoice = (Invoice)tag;
            Program.LoadEditorAsync(new InvoiceSalesEditor(Program, invoice));

            base.PerformEditorOpen(tag);
        }
    }
}